/**
 */
package edu.ar.tesis.stepbystep.impl;

import edu.ar.tesis.stepbystep.MobilApp;
import edu.ar.tesis.stepbystep.Setting;
import edu.ar.tesis.stepbystep.StepbystepPackage;
import edu.ar.tesis.stepbystep.View;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Mobil App</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link edu.ar.tesis.stepbystep.impl.MobilAppImpl#getASetting <em>ASetting</em>}</li>
 *   <li>{@link edu.ar.tesis.stepbystep.impl.MobilAppImpl#getAView <em>AView</em>}</li>
 *   <li>{@link edu.ar.tesis.stepbystep.impl.MobilAppImpl#getName <em>Name</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class MobilAppImpl extends EObjectImpl implements MobilApp {
	/**
	 * The cached value of the '{@link #getASetting() <em>ASetting</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getASetting()
	 * @generated
	 * @ordered
	 */
	protected Setting aSetting;

	/**
	 * The cached value of the '{@link #getAView() <em>AView</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getAView()
	 * @generated
	 * @ordered
	 */
	protected EList<View> aView;

	/**
	 * The default value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected static final String NAME_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getName() <em>Name</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getName()
	 * @generated
	 * @ordered
	 */
	protected String name = NAME_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected MobilAppImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return StepbystepPackage.Literals.MOBIL_APP;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Setting getASetting() {
		return aSetting;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetASetting(Setting newASetting, NotificationChain msgs) {
		Setting oldASetting = aSetting;
		aSetting = newASetting;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, StepbystepPackage.MOBIL_APP__ASETTING, oldASetting, newASetting);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setASetting(Setting newASetting) {
		if (newASetting != aSetting) {
			NotificationChain msgs = null;
			if (aSetting != null)
				msgs = ((InternalEObject)aSetting).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - StepbystepPackage.MOBIL_APP__ASETTING, null, msgs);
			if (newASetting != null)
				msgs = ((InternalEObject)newASetting).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - StepbystepPackage.MOBIL_APP__ASETTING, null, msgs);
			msgs = basicSetASetting(newASetting, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StepbystepPackage.MOBIL_APP__ASETTING, newASetting, newASetting));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<View> getAView() {
		if (aView == null) {
			aView = new EObjectContainmentEList<View>(View.class, this, StepbystepPackage.MOBIL_APP__AVIEW);
		}
		return aView;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getName() {
		return name;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setName(String newName) {
		String oldName = name;
		name = newName;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, StepbystepPackage.MOBIL_APP__NAME, oldName, name));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case StepbystepPackage.MOBIL_APP__ASETTING:
				return basicSetASetting(null, msgs);
			case StepbystepPackage.MOBIL_APP__AVIEW:
				return ((InternalEList<?>)getAView()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case StepbystepPackage.MOBIL_APP__ASETTING:
				return getASetting();
			case StepbystepPackage.MOBIL_APP__AVIEW:
				return getAView();
			case StepbystepPackage.MOBIL_APP__NAME:
				return getName();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case StepbystepPackage.MOBIL_APP__ASETTING:
				setASetting((Setting)newValue);
				return;
			case StepbystepPackage.MOBIL_APP__AVIEW:
				getAView().clear();
				getAView().addAll((Collection<? extends View>)newValue);
				return;
			case StepbystepPackage.MOBIL_APP__NAME:
				setName((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case StepbystepPackage.MOBIL_APP__ASETTING:
				setASetting((Setting)null);
				return;
			case StepbystepPackage.MOBIL_APP__AVIEW:
				getAView().clear();
				return;
			case StepbystepPackage.MOBIL_APP__NAME:
				setName(NAME_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case StepbystepPackage.MOBIL_APP__ASETTING:
				return aSetting != null;
			case StepbystepPackage.MOBIL_APP__AVIEW:
				return aView != null && !aView.isEmpty();
			case StepbystepPackage.MOBIL_APP__NAME:
				return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (name: ");
		result.append(name);
		result.append(')');
		return result.toString();
	}

} //MobilAppImpl
